<!DOCTYPE html>
<title>media controls cast button</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../media-controls.js"></script>
<video controls width="500"></video>
<script>
async_test(function(t) {
    var video = document.querySelector("video");
    video.src = "../content/test.ogv";

    video.onloadedmetadata = t.step_func_done(function() {
        // Should not have a cast button by default
        assert_false(isCastButtonEnabled(video), "button should not be enabled with no cast devices");

        // Pretend we have a cast device
        internals.mediaPlayerRemoteRouteAvailabilityChanged(video, true);

        // Now should have cast button
        assert_true(isCastButtonEnabled(video), "button should exist");

        // Check that we don't have an overlay cast button
        var overlayButton = overlayCastButton(video);
        assert_equals(overlayButton.style.display, "none", "Overlay button should not be visible with controls");

        // Remove cast device - cast button should go away
        internals.mediaPlayerRemoteRouteAvailabilityChanged(video, false);
        assert_false(isCastButtonEnabled(video), "button should not be visible after cast device goes away");
    });
});
</script>
